package com.taoyibao.hongcanting.ui.login.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.base.activity.BaseActivityPresenter;
import com.taoyibao.hongcanting.ui.login.delegate.RegisterDelegate;
import com.taoyibao.hongcanting.utils.CodeUtils;

/**
 * @author TangAnna
 * @description: 注册
 * @date :${DATA} 15:39
 */
public class RegisterActivity extends BaseActivityPresenter<RegisterDelegate> implements View.OnClickListener {
    @Override
    protected Class<RegisterDelegate> getDelegateClass() {
        return RegisterDelegate.class;
    }

    @Override
    protected void bindEvenListener() {
        super.bindEvenListener();
        setListener();
    }

    private void setListener() {
        viewDelegate.get(R.id.tv_register_getVCode).setOnClickListener(this);
        viewDelegate.get(R.id.btn_register_next).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_register_getVCode://获取验证码
                if (viewDelegate.isCanVCode()) {
                    getVcode();
                }
                break;
            case R.id.btn_register_next://下一步
                if (viewDelegate.isCanNext()) {
                    onNext();
                }
                break;
        }
    }

    /**
     * 获取验证码
     */
    public void getVcode() {
        //TODO 获取验证码接口
        CodeUtils.setSecurityTextView((TextView) viewDelegate.get(R.id.tv_register_getVCode));
    }

    /**
     * 下一步操作
     */
    public void onNext() {
        //TODO 调用下一步接口
        startActivity(new Intent(this, SetLoginPwdActivity.class));
    }

}
